//
//  UserDefinedCellForOtherChargeList.m
//  HondaPro_2
//
//  Created by Eric on 13-6-5.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "UserDefinedCellForOtherChargeList.h"

@interface UserDefinedCellForOtherChargeList ()

//创建 labels
-(void)initLabesOnCell;

@end

@implementation UserDefinedCellForOtherChargeList

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        [self initLabesOnCell];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - 创建 labels

-(void)initLabesOnCell
{
    self.dicForLabelsOnCell = [NSMutableDictionary dictionaryWithCapacity:4];
    
    NSArray *arrForKeys = [NSArray arrayWithObjects:
                           @"indexForUsePart",
                           @"ADD_ITEM_CODE",
                           @"ADD_ITEM_NAME",
                           @"ADD_ITEM_AMOUNT", nil];
    
    //给字典中 添加 4 个label，因为cell上有 4 项要显示
    for (int i = 0; i<4; i++)
    {
        UILabel *lbl = [[UILabel alloc] init];
        lbl.backgroundColor = [UIColor clearColor];
        lbl.font = [UIFont systemFontOfSize:13];
        lbl.textColor = [UIColor darkGrayColor];
        [self.contentView addSubview:lbl];
        [self.dicForLabelsOnCell setValue:lbl forKey:[arrForKeys objectAtIndex:i]];
        
        if ([[arrForKeys objectAtIndex:i] isEqualToString:@"indexForUsePart"])
        {
            lbl.textAlignment = NSTextAlignmentCenter;
        }
    }
    
    //给字典中的 label 设置 rectangle
    ((UILabel *)[self.dicForLabelsOnCell objectForKey:@"indexForUsePart"]).frame =
    CGRectMake(1, 0, 60, 50);
    
    ((UILabel *)[self.dicForLabelsOnCell objectForKey:@"ADD_ITEM_CODE"]).frame =
    CGRectMake(62, 0, 310, 50);
    
    ((UILabel *)[self.dicForLabelsOnCell objectForKey:@"ADD_ITEM_NAME"]).frame =
    CGRectMake(373, 0, 310, 50);
    
    ((UILabel *)[self.dicForLabelsOnCell objectForKey:@"ADD_ITEM_AMOUNT"]).frame =
    CGRectMake(684, 0, 195, 50);
}

@end
